package cn.liutao.common.entity;



import cn.liutao.auth.entity.po.User;
import lombok.Data;

/**
 * @author liutao
 * @Description 全局用户
 * @date 2023/10/30 23:44
 * @Version 1.0
 */
@Data
public class LoginUser {

    private static final ThreadLocal<User> userInfo = new ThreadLocal<>();

    public static void addLoginUser(User user){
        userInfo.set(user);
    }

    public static User getLoginUser(){
        return userInfo.get();
    }

    public static Integer getUserId(){
        return userInfo.get().getId();
    }

    public static void removeLoginUser(){
        userInfo.remove();
    }
}
